<!-- index.html -->
<script>
    const socket = new WebSocket('ws://' + '116.205.185.181:8000' + '/ws/connection-test/');
    
    // 连接成功回调
    socket.onopen = (event) => {
        console.log('[Client] 已连接服务端');
        document.body.style.backgroundColor = '#dff0d8';  // 视觉反馈
    };
    
    // 错误处理
    socket.onerror = (error) => {
        console.error('连接错误:', error);
        document.body.style.backgroundColor = '#f2dede';
    };
    
    // 关闭处理
    socket.onclose = (event) => {
        console.log(`连接关闭，代码: ${event.code}`);
    };
    </script>